package org.jeecg.modules.purchase.mapper;

import java.util.List;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.purchase.entity.MerchantProvider;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: 供应商
 * @Author: jeecg-boot
 * @Date:   2022-12-21
 * @Version: V1.0
 */
public interface MerchantProviderMapper extends BaseMapper<MerchantProvider> {
    
    @InterceptorIgnore(tenantLine = "true")
    @Select("SELECT  id,code,name,short_name,provider_status,provider_type,business_scope,contract_number,start_time,end_time,contract_attachment,legal_representative,representative_phone,policy,clearing_form,opening_bank,username,payment_account,remark,status_flag,create_by,create_time,update_by,update_time,del_flag,sys_org_code,tenant_id  FROM merchant_provider \n" +
            " WHERE  del_flag=0\n" +
            "\n" +
            "AND (end_time < #{expriedDay} AND end_time > now()\n" +
            "AND del_flag = 0 AND status_flag = 'Y')")
    public List<MerchantProvider> getExpried(@Param("expriedDay")String expriedDay);
    
    /**
     * 获取指定合同结束日期的数据
     * @param expriedDay
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    @Select("SELECT  id,code,name,short_name,provider_status,provider_type,business_scope,contract_number,start_time,end_time,contract_attachment,legal_representative,representative_phone,policy,clearing_form,opening_bank,username,payment_account,remark,status_flag,create_by,create_time,update_by,update_time,del_flag,sys_org_code,tenant_id  FROM merchant_provider \n" +
            " WHERE  del_flag=0\n" +
            "\n" +
            "AND end_time = #{expriedDay}")
    public List<MerchantProvider> getByEndTime(@Param("expriedDay")String expriedDay);
    @InterceptorIgnore(tenantLine = "true")
    @Update("UPDATE merchant_provider SET status_flag = 'N', provider_status = '3', update_time = NOW(), update_by = '管理员' \n" +
            "WHERE del_flag = 0 AND id = #{id}")
    Boolean expriedUpdate(@Param("id")String id);
}